package com.mep.backup.controller;


import com.mep.backup.bifeign.IFeignSysUserApi;
import com.mep.backup.feign.IFeignStoryApi;
import com.mep.common.http.HttpResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiOperationSupport;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.security.RolesAllowed;

@Api(value="002-story的controller",tags="002-story的controller")
@RestController
@RequestMapping("story")
public class StoryController implements IFeignStoryApi {

    @Autowired
    private IFeignSysUserApi feignSysUserApi;
    @Override
    @ApiOperation(value="01.飞龙在天(通过feign调用story-auth微服务)",notes="问题点:飞龙在天")
    @ApiOperationSupport(order = 1, author = "lyl")
    @PostMapping("/fei")
    public HttpResult feiLongZaiTian() {
        //String name = "飞龙在天";
        HttpResult httpResult = feignSysUserApi.findByName("admin");
        //httpResult.setMsg(name);
        return httpResult;
    }

    @Override
    //@PreAuthorize("admin")
    //@RolesAllowed("admin")
    @ApiOperation(value="02.无忧无虑",notes="问题点:无忧无虑")
    @ApiOperationSupport(order = 2, author = "lyl")
    @PostMapping("/wu")
    public HttpResult wuYouWuLv() {
        String name = "无忧无虑";
        return HttpResult.ok(name);
    }
}
